from django.db import models
from django.conf import settings


# Create your models here.

__all__ = [
    "MyShell",
]

# 脚本表
class MyShell(models.Model):
    title = models.CharField(max_length=40, verbose_name="脚本名称")
    shell = models.TextField(verbose_name="shell脚本")
    encoding = models.CharField(max_length=16,default='gbk',verbose_name='编码格式')
    stderr = models.TextField(blank=True, null=True, verbose_name="失败信息")
    stdout = models.TextField(blank=True, null=True, verbose_name="成功信息")
    returncode = models.BooleanField(blank=True, null=True, default=None, verbose_name='执行结果')
    shell_status = models.BooleanField(blank=True, null=True, default=None, verbose_name='是否关闭进程')
    file_status = models.BooleanField(blank=True, null=True, default=None, verbose_name='是否删除文件')
    pid = models.IntegerField(blank=True, null=True,default=None,verbose_name='进程号')
    os = models.IntegerField(choices=settings.MODELS_CHOICES['my_shell']['system'],default=1,verbose_name='操作系统')

    create_time = models.DateTimeField(blank=True, null=True, verbose_name="创建日期")
    update_time = models.DateTimeField(blank=True, null=True, verbose_name="更新日期")

    class Meta:
        verbose_name = '脚本'
        verbose_name_plural = '脚本'

    def __str__(self):
        return self.title
